package org.example.mapping;

import lombok.Data;
import org.example.config.Configuration;

import java.util.ArrayList;
import java.util.List;

//语句的映射关系
@Data
public final class MappedStatement {
    private String id;
    private Configuration configuration;
    private String resource;
    private SqlSource sqlSource;
    private Class<?> resultType;
    private Class<?> parameterType;
    private List<ResultMap> resultMaps;

    public MappedStatement(String id, String resource, Configuration configuration, SqlSource sqlSource, Class<?> resultType, Class<?> parameterType) {
        this.id = id;
        this.resource = resource;
        this.configuration = configuration;
        this.sqlSource = sqlSource;
        this.resultType = resultType;
        this.parameterType = parameterType;
        getStatementResultMaps();
    }

    public void getStatementResultMaps(){
        this.resultMaps = new ArrayList<>();
        ResultMap resultMap = new ResultMap(configuration, id + "-Inline",resultType, new ArrayList<>());
        resultMaps.add(resultMap);
    }

    public SqlCommandType getSqlCommandType() {
        //TODO
        return SqlCommandType.SELECT;
    }

    public List<ResultMap> getResultMaps() {
        return this.resultMaps ;
    }
}
